<?
require 'global.php';

// 是否为首页 am I index ?
$index=1;
// 友情连接
$link=new DB(Tlink,$conn);

// banners 幻灯片
$arr_banner = $banner->get_rows(16,'','','seq_no');

// ad 广告
$tem=$ad->get_rows(16,'category_id',1);
shuffle($tem);
$ad_right=$tem[0];
$tem=$ad->get_rows(16,'category_id',2);
shuffle($tem);
$ad_bar=$tem[0];

// 公告和新闻
$where=array();
$where[]=array('name'=>'language_id','val'=>$lang_id);
$where[]=array('name'=>'category_id','val'=>1);
$arr_notice = $news->get_rows_advanced(5,$where,'id');
$where=array();
$where[]=array('name'=>'language_id','val'=>$lang_id);
$where[]=array('name'=>'category_id','val'=>2);
$arr_news = $news->get_rows_advanced(5,$where,'id');

// 推荐产品 featured_products
$tem = $product->get_rows(16,'is_enabled',1,'is_featured','desc');
shuffle($tem);
$arr_featured=array();
$k=0;
foreach($tem as $row) { $arr_featured[]=$row; $k++; if($k==MAX_FEATURED_PRODUCT_SHOWN) break; }

// 热销产品 hot_products
$tem = $product->get_rows(16,'is_enabled',1,'sold_quantity','desc');
//shuffle($tem);
$arr_hot=array();
$k=0;
foreach($tem as $row) { $arr_hot[]=$row; $k++; if($k==MAX_HOT_PRODUCT_SHOWN) break; }

// 新产品 new_products
$tem = $product->get_rows(16,'is_enabled',1,'id','desc');
//shuffle($tem);
$arr_new=array();
$k=0;
foreach($tem as $row) { $arr_new[]=$row; $k++; if($k==MAX_NEW_PRODUCT_SHOWN) break; }

// 友情链接
$arr_link = $link->get_rows(32,'language_id',$lang_id,'seq_no');

// SEO 设置 seo tags
$title=$config['SITE_TITLE_'.LANG];
$kwd=$title;
$dpn=$kwd;

// view 加载视图
require VIEW.'index_copy.php';

// end of file
